(:
  A procedure to select the first and last timestamp from DREW and COFFEE files
:)
declare boundary-space strip;

import module namespace
    jj = "http://kumquat.emse.fr/utilitaires"
    at "jjutils.xq" ;

let $doc := doc($arguments[1])
let $isdrew := $arguments[2] = "Drew"
let $starttime := if ($isdrew) then
		$doc/trace/event[1]/time/date
	else
		$doc//record[1]//@millis
let $endtime := if ($isdrew) then
		$doc/trace/event[last()]/time/date
	else
		$doc//record[last()]//@millis
		
return
<display>{
  <item>
    <info name="firsttime">{xs:string($starttime[1])}</info>
    <info name="lasttime">{xs:string($endtime[1])}</info>
  </item>
}</display>
